import 'package:flutter/material.dart';
import 'package:happy_elf_app/utils/color.dart';
import 'package:happy_elf_app/views/Space/widget/goTogether.dart';
import 'package:happy_elf_app/views/Space/widget/publish.dart';
import 'package:happy_elf_app/views/Space/widget/togetherCenter.dart';
import 'package:happy_elf_app/widgets/headerBack/index.dart';

class Together extends StatefulWidget {
  const Together({super.key});

  @override
  State<Together> createState() => _TogetherState();
}

class _TogetherState extends State<Together>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;

  List btnList = [
    {'title': '发布结伴招募', 'type': 1},
    {'title': '查看结伴申请', 'type': 2},
    {'title': '查看招募中心', 'type': 3},
  ];
  int page = 0; // 页面

  @override
  void initState() {
    super.initState();
    // 是否有精灵，有获取结伴关系，没有显示创建
    // 获取是否有结伴关系，有的话显示，没有显示三个按钮
    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          HeaderBack(title: '结伴空间', isFirst: false, callback: () {}),
          SizedBox(height: 100),
          page == 0 ? 
          Column(
            children: [...btnList.map((item) => 
            GestureDetector(
              child: Container(
                padding: EdgeInsets.symmetric(horizontal: 10, vertical: 16),
                decoration: BoxDecoration(
                  color: hexColor('#ffffff'),
                  boxShadow: const [
                    BoxShadow(
                      color: Color(0x19000000),
                      blurRadius: 4,
                      offset: Offset(4, 4),
                      spreadRadius: 0,
                    )
                  ],
                ),
                child: Text(item['title']),
              ),
              onTap: () {
                page = item['type'];
              },
            )
          )],
          ) : page == 1 ? goTogether() : page == 2 ? publish() : togetherCenter()
        ],
      ),
    );
  }
}
